package tv.acgn.advertisement.servicebase.utils;

/**
 * @author : junG
 * @program : advertisement-advertisement-ad-service-base-utils
 * @description : 线程本地变量工具类
 * @date : 2019-06-01 18:25
 **/

public class ThreadLocalUtils {

    private static <T> ThreadLocal getInstance(T clazz) {
        ThreadLocal<T> threadLocal = new ThreadLocal<T>() {
            @Override
            protected T initialValue() {
                Object o = new Object();
                return (T)o;
            }
        };
        return threadLocal;
    }

    public static <T> void add(T value, ThreadLocal local) {
        local.set(value);
    }

    public static <T> T getId(ThreadLocal local) {
        T t = (T)local.get();
        return t;
    }

    public static void remove(ThreadLocal local) {
        local.remove();
    }
}
